//
// Created by francklinson on 2021/11/18 AT 10:19.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    bool checkOnesSegment(string s) {
        // 符合条件的string  一定是开头一段连续的1，后面全是0
        int seg = 0; // 连续1段数
        for (int i = 1; i < s.size(); ++i) {
            if (s[i] == '0' && s[i - 1] == '1') {
                // 一段1结束
                ++seg;
            }
            if (s[i] == '1' && seg > 0) {
                return false;
            }
        }
        return true;
    }

    bool checkOnesSegment2(string s) {
        return s.find('1', s.find('0')) == string::npos; // 有没有出现'01'这样的形式
    }
};

int main() {
    Solution solution;
    cout << solution.checkOnesSegment("1100") << endl;
    cout << solution.checkOnesSegment("1101") << endl;
    return 0;
}

